package hotactivity

import (
	"time"
)

//活动信息
const (
	HOTACTIVITY_STATUS_PUBLISH    int = 1 //已发布
	HOTACTIVITY_STATUS_PREPUBLISH int = 3 //未发布
	HOTACTIVITY_STATUS_EXPIRED    int = 2 //已过期
	HOTACTIVITY_STATUS_DELETE     int = 4 //已删除
)

const (
	MAX_LENGTH = 20
)

var (
	hotactivityinfoService *HotActivityInfoService
)

type HotActivityInfoService struct {
}

func GetHotActivityInfoService() *HotActivityInfoService {
	if hotactivityinfoService == nil {
		hotactivityinfoService = &HotActivityInfoService{}
	}
	return hotactivityinfoService
}

type HotActivityInfo struct {
	ActivityId   int64  `json:"activity_id"`
	ThumbnailURL string `json:"thumbnail_url"`
	Size         string `json:"size"`
	Title        string `json:"title"`
	TargetURL    string `json:"target_url"`
	PublishTick  int64  `json:"publish_tick"`
	EndTick      int64  `json:"end_tick"`
	Status       int    `json:"status"`
}

//获取当前状态
func (p *HotActivityInfo) GetStatus() int {
	currentTick := time.Now().Unix()
	if p.PublishTick > currentTick {
		return HOTACTIVITY_STATUS_PREPUBLISH
	}
	if p.EndTick >= currentTick {
		return HOTACTIVITY_STATUS_PUBLISH
	}
	return HOTACTIVITY_STATUS_EXPIRED
}
